1、**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    vector<vector<int>> levelOrder(TreeNode* root) {
        vector<vector<int>> vv;
        if(root==nullptr)
            return vv;
        vector<int> v;
        queue<TreeNode*> q;
        q.push(root);
        int a=0;
        while(!q.empty())
        {
            a++;
            int n=q.size();
            while(n--)
            {
                TreeNode* front=q.front();
                v.push_back(front->val);
                q.pop();
                if(front->left)
                    q.push(front->left);
                if(front->right)
                    q.push(front->right);
            }
            if(a%2)
            {
                vv.push_back(v);
            }
            else
            {
                reverse(v.begin(),v.end());
                vv.push_back(v);
            }
            v.clear();
        }
        return vv;
    }
};

2、
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    vector<int> levelOrder(TreeNode* root) {
        vector<int> v;
        
        if(root==nullptr)
        {
            return v;
        }
        queue<TreeNode*> q;
        q.push(root);
        while(!q.empty())
        {
            TreeNode* p=q.front();
            q.pop();

            v.push_back(p->val);
            if(p->left)
                q.push(p->left);
            if(p->right)
                q.push(p->right);
        }
        return v;
    }
};